<template>
    <div class="page_orderList">
        <div class="title">我的收藏</div>
        <el-form :inline="true" :model="searchForm" ref="searchForm" @keyup.enter.native="search" :size="size">
            <el-form-item label="产品名称" prop="orderNO">
                <el-input v-model="searchForm.title" placeholder="产品名称" clearable></el-input>
            </el-form-item>
            <el-button type="primary" icon="el-icon-search" :size="size" @click="search">查询</el-button>
            <el-button @click="resetSearch" icon="el-icon-refresh" :size="size">重置</el-button>
        </el-form>

        <div class="tableBox">
            <el-table :data="dataList" border style="width: 100%;" height="100%">
                <el-table-column header-align="center" align="center"
                                 min-width="100" label="产品名称">
                    <template slot-scope="{row}">
                        <span style="color: #3a8ee6; cursor: pointer" @click="goInfoDetail(row)">{{row.title}}</span>
                    </template>
                </el-table-column>
                <el-table-column prop="description" header-align="center" align="center" label="产品描述" min-width="200"></el-table-column>
                <el-table-column prop="price" header-align="center" align="center" label="价格(元)" width="100"></el-table-column>
                <el-table-column prop="vipDiscount" header-align="center" align="center" label="vip折扣" width="80"></el-table-column>
            </el-table>
        </div>
        <pagination v-show="total>0" :total="total" :page.sync="searchForm.pageNum" :limit.sync="searchForm.pageSize" @pagination="getDataList" />
    </div>
</template>

<script>
  import {collectPage} from '@/api/info'
  import { mapGetters } from 'vuex'
  import Pagination from '@/components/Pagination'
  export default {
    name: 'orderList',
    components: {
      Pagination,
    },
    data() {
      return {
        dataList: [],
        searchForm: {
          orderNO: '',
          tripDay: '',
          pageNum: 1,
          pageSize: 10,
        },
        total: 0,
        propInfo: {},
        dialogAppraiseShow: false
      }
    },
    computed: {
      ...mapGetters(['size']),
    },
    created() {
      this.getDataList()
    },
    methods: {
      // 获取数据列表
      getDataList () {
        collectPage(this.searchForm).then((res) => {
          let {data, total} = res
          this.dataList = data
          this.total = parseInt(total)
        }).catch((res) => {
        })
      },
      // 重置
      resetSearch () {
        this.$refs['searchForm'].resetFields()
      },
      // 查询
      search () {
        this.searchForm.pageNum = 1
        this.getDataList()
      },
      addAppraise(row) {
        this.propInfo = row
        this.dialogAppraiseShow = true
      },
      goInfoDetail(row) {
        let {infoId} = row
        this.$router.push({
          name: 'travelDetail',
          query: {
            infoId: infoId
          }
        })
      },
    }
  }
</script>

<style lang="scss">
    .page_orderList {
        padding: 20px;
        height: calc(100% - 50px);
        display: flex;
        flex-direction: column;
        box-sizing: border-box;
        .title {
            font-size: 28px;
            padding-bottom: 10px;
            font-weight: bold;
        }
        .tableBox {
            flex: 1;

        }
    }
</style>
